<%@page import="java.io.PrintWriter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>


	<%
		int i, j, k, l;
		int starNum = 5;
		out.println("<hr/>1、直角三角形：<br/>");
		for (i = 1; i <= starNum; i++) {
			for (j = 1; j <= i; j++) {
				out.println("* ");
			}
			out.print("<br/>");
		}

		out.println("<hr/>2、上图翻转：<br/>");
		l = starNum;
		for (i = 1; i <= starNum; i++) {
			for (j = l--; j > 1; j--) {
				out.println("&nbsp;&nbsp;");
			}
			for (k = 1; k <= i; k++) {
				out.print("* ");
			}
			out.print("<br/>");
		}

		out.println("<hr/>3、上图翻转：<br/>");
		for (i = starNum; i > 0; i--) {
			for (j = 1; j <= i; j++) {
				out.print("* ");
			}
			out.print("<br/>");
		}

		out.println("<hr/>4、上图翻转：<br/>");
		l = starNum;
		for (i = 0; i < starNum; i++) {
			for (j = 0; j < i; j++) {
				out.println("&nbsp;&nbsp;");
			}
			for (k = l--; k > 0; k--) {
				out.print("* ");
			}
			out.print("<br/>");
		}

		out.println("<hr/>5、等腰三角形：<br/>");
		l = starNum;
		for (i = 0; i < starNum; i++) {
			for (k = l--; k > 1; k--) {
				out.println("&nbsp;&nbsp;");
			}
			for (j = 0; j < (2 * i + 1); j++) {
				out.print("* ");
			}
			out.print("<br/>");
		}

		out.println("<hr/>6、菱形：<br/>");
		l = starNum;
		for (i = 0; i < starNum; i++) {
			for (k = l--; k > 1; k--) {
				out.println("&nbsp;&nbsp;");
			}
			for (j = 0; j < (2 * i + 1); j++) {
				out.print("* ");
			}
			out.print("<br/>");
		}
		l = starNum - 2;
		for (i = 0; i < starNum - 1; i++) {
			for (j = 0; j <= i; j++) {
				out.println("&nbsp;&nbsp;");
			}
			for (k = 2 * (l--) + 1; k >= 1; k--) {
				out.print("* ");
			}
			out.print("<br/>");
		}

		out.println("<hr/>7、空心菱形：<br/>");
		l = starNum;
		int index;
		for (i = 0; i < starNum; i++) {
			index = 1;
			for (k = l--; k > 1; k--) {
				out.println("&nbsp;&nbsp;");
			}
			for (j = 0; j < (2 * i + 1); j++) {
				if (index == 1 || j == 2 * i) {
					out.print("* ");
				} else {
					out.println("&nbsp;&nbsp;");
				}
				index++;
			}
			out.print("<br/>");
		}
		l = starNum - 2;
		for (i = 0; i < starNum - 1; i++) {
			index = 1;
			for (j = 0; j <= i; j++) {
				out.println("&nbsp;&nbsp;");
			}
			for (k = 2 * (l--) + 1; k >= 1; k--) {
				if (index == 1 || k == 1) {
					out.print("* ");
				} else {
					out.println("&nbsp;&nbsp;");
				}
				index++;
			}
			out.print("<br/>");
		}

		out.println("<hr/>8、求100-200之间的素数：<br/>");
		boolean isPrimeNum;
		for (i = starNum; i <= starNum; i++) {
			isPrimeNum = true;
			for (j = 2; j <= i / 2; j++) {
				if (i % j == 0) {
					isPrimeNum = false;
					break;
				}
			}
			if (isPrimeNum) {
				out.print(i + "  ");
			}
		}

		out.println("<hr/>9、求斐波拉契数列前20个数：<br/>");
		i = 0;//计数
		j = 0;//前一个数
		k = 1;//后一个数
		out.print(0 + "  " + 1 + "  ");
		while (i < starNum - 2) {
			l = j + k;
			out.print(l + "  ");
			j = k;
			k = l;
			i++;
		}

		out.println("<hr/>10、求百元买百鸡。公：5 母：3 小：1元3个：<br/>");
		for (i = 0; i <= 20; i++) {
			for (j = 0; j <= 33; j++) {
				for (k = 0; k < 100; k += 3) {
					if (((5 * i) + (3 * j) + (k * 1 / 3) == 100)
							&& (i + j + k == 100)) {
						out.print("公鸡" + i + "只，母鸡" + j + "只，小鸡" + k
								+ "只<br/>");
					}
				}
			}
		}

		out.println("<hr/>11、求5阶乘：");
		int result = 1;
		for (i = starNum; i >= 1; i--) {
			result = result * i;
		}
		out.print(result);

		out.println("<hr/>12、求水仙花数(100-999)：");
		for (i = 100; i < 1000; i++) {
			j = (i / 100);
			k = (i / 10 - j * 10);
			l = i % 10;
			//out.print(j +"-"+ k + "-" + l + "<br/>");
			if (j * j * j + k * k * k + l * l * l == i) {
				out.print(i + "  ");
			}
		}
		out.println("<hr/>");
	%>
</body>
</html>